#lang rosetta-racket


(provide
 ; intersect
 intersect-overlaping-shapes
 intersect-non-overlaping-shapes
 intersect-bigger-contained-shapes
 intersect-smaller-contained-shapes
 
 intersect-overlaping-shapes-repeat
 intersect-non-overlaping-shapes-repeat
 intersect-smaller-contained-shapes-repeat
 intersect-smaller-contained-shapes-repeat
 
 ; subtract
 subtract-overlaping-shapes
 subtract-non-overlaping-shapes
 subtract-bigger-contained-shapes
 subtract-smaller-contained-shapes
 
 subtract-overlaping-shapes-repeat
 subtract-non-overlaping-shapes-repeat
 subtract-bigger-contained-shapes-repeat
 subtract-smaller-contained-shapes-repeat
 
 ; union
 union-overlaping-shapes
 union-non-overlaping-shapes
 union-bigger-contained-shapes
 union-smaller-contained-shapes
 
 union-overlaping-shapes-repeat
 union-non-overlaping-shapes-repeat
 union-bigger-contained-shapes-repeat
 union-smaller-contained-shapes-repeat)


; intersect

(define (intersect-overlaping-shapes)
  (lift
   (thunk (displayln "Intersection of two overlaping shapes"))
   (intersect (sphere (x 1) 2) (sphere (x -1) 2))))

(define (intersect-non-overlaping-shapes)
  (lift
   (thunk (displayln "Intersection of two non-overlaping shapes"))
   (intersect (sphere (x 1) 1) (sphere (x -1) 1))))

(define (intersect-bigger-contained-shapes)
  (lift
   (thunk (displayln "Intersection of two shapes, one contained in the other, bigger /\\ smaller"))
   (intersect (sphere 2) (sphere 1))))

(define (intersect-smaller-contained-shapes)
  (lift
   (thunk (displayln "Intersection of two shapes, one contained in the other, smaller /\\ bigger"))
   (intersect (sphere 1) (sphere 2))))


(define (intersect-overlaping-shapes-repeat)
  (lift
   (thunk (displayln "Intersection of three overlaping shapes"))
   (intersect (sphere (x 1) 2) (sphere (x -1) 2) (sphere (y 1) 2))))

(define (intersect-non-overlaping-shapes-repeat)
  (lift
   (thunk (displayln "Intersection of three non-overlaping shapes"))
   (intersect (sphere (x 1) 1) (sphere (x -1) 1) (sphere (y 1) 1))))

(define (intersect-bigger-contained-shapes-repeat)
  (lift
   (thunk (displayln "Intersection of three shapes, bigger /\\ smaller /\\ even bigger"))
   (intersect (sphere 2) (sphere 1) (sphere 3))))

(define (intersect-smaller-contained-shapes-repeat)
  (lift
   (thunk (displayln "Intersection of two shapes, one contained in the other, smaller /\\ bigger /\\ even bigger"))
   (intersect (sphere 1) (sphere 2) (sphere 3))))


; subtract

(define (subtract-overlaping-shapes)
  (lift
   (thunk (displayln "Subtraction of two overlaping shapes"))
   (subtract (sphere (x 1) 2) (sphere (x -1) 2))))

(define (subtract-non-overlaping-shapes)
  (lift
   (thunk (displayln "Subtraction of two non-overlaping shapes"))
   (subtract (sphere (x 2) 1) (sphere (x -2) 1))))

(define (subtract-bigger-contained-shapes)
  (lift
   (thunk (displayln "Subtraction of two shapes, one contained in the other, bigger - smaller"))
   (subtract (sphere 2) (sphere 1))))

(define (subtract-smaller-contained-shapes)
  (lift
   (thunk (displayln "Subtraction of two shapes, one contained in the other, smaller - bigger"))
   (subtract (sphere 1) (sphere 2))))


(define (subtract-overlaping-shapes-repeat)
  (lift
   (thunk (displayln "Subtraction of three overlaping shapes"))
   (subtract (sphere (x 1) 2) (sphere (x -1) 2) (sphere 2))))

(define (subtract-non-overlaping-shapes-repeat)
  (lift
   (thunk (displayln "Subtraction of three non-overlaping shapes"))
   (subtract (sphere (x 2) 1) (sphere (x -2) 1) (sphere (y 2) 1))))

(define (subtract-bigger-contained-shapes-repeat)
  (lift
   (thunk (displayln "Subtraction of three shapes, contained in each other, bigger - smaller - even bigger"))
   (subtract (sphere 2) (sphere 1) (sphere 3))))

(define (subtract-smaller-contained-shapes-repeat)
  (lift
   (thunk (displayln "Subtraction of three shapes, contained in each other, smaller - bigger - even bigger"))
   (subtract (sphere 1) (sphere 2) (sphere 3))))


; union

(define (union-overlaping-shapes)
  (lift
   (thunk (displayln "Union of two overlaping shapes"))
   (union (sphere (x 1) 2) (sphere (x -1) 2))))

(define (union-non-overlaping-shapes)
  (lift
   (thunk (displayln "Union of two non-overlaping shapes"))
   (union (sphere (x 2) 1) (sphere (x -2) 1))))

(define (union-bigger-contained-shapes)
  (lift
   (thunk (displayln "Union of two shapes, one contained in the other, bigger U smaller"))
   (union (sphere 2) (sphere 1))))

(define (union-smaller-contained-shapes)
  (lift
   (thunk (displayln "Subtraction of two shapes, one contained in the other, smaller U bigger"))
   (union (sphere 1) (sphere 2))))


(define (union-overlaping-shapes-repeat)
  (lift
   (thunk (displayln "Union of three overlaping shapes"))
   (union (sphere (x 1) 2) (sphere (x -1) 2) (sphere 2))))

(define (union-non-overlaping-shapes-repeat)
  (lift
   (thunk (displayln "Union of three non-overlaping shapes"))
   (union (sphere (x 2) 1) (sphere (x -2) 1) (sphere (y 2) 1))))

(define (union-bigger-contained-shapes-repeat)
  (lift
   (thunk (displayln "Union of three shapes, contained in each other, bigger U smaller U even bigger"))
   (union (sphere 2) (sphere 1) (sphere 3))))

(define (union-smaller-contained-shapes-repeat)
  (lift
   (thunk (displayln "Union of three shapes, contained in each other, smaller U bigger U even bigger"))
   (union (sphere 1) (sphere 2) (sphere 3))))